<template name="appVerifyTxid">

{{#with tx}}
  {{#if error}}
    <h3 class="ui pageHeader header">
      <i class="tiny plus icon"></i>
      <div class="content wordBreak">
        Transaction {{tx.parameter}}
      </div>
    </h3>
    <div class="ui negative message">
      <i class="close icon"></i>
      <div class="header">
        Error reading transaction
      </div>
      <p>{{tx.error}}</p>
    </div>
  {{else}}
    {{#if notFound}}
      <h3 class="ui pageHeader header">
        <i class="tiny plus icon"></i>
        <div class="content wordBreak">
          Transaction {{tx.parameter}}
        </div>
      </h3>
      <div class="ui negative message">
        <i class="close icon"></i>
        Transaction <span class="hack">{{id}}</span> not found
      </div>
    {{else}}
      <h3 class="ui pageHeader header">
        <i class="tiny plus icon"></i>
        <div class="content wordBreak">
          Transaction {{tx.tx.transaction_hash}}
        </div>
      </h3>

      <div class="ui segment pageSegment">

        <div class="description">
          <div class="ui celled horizontal list">
            <div class="item"><strong>Confirmations</strong> {{#if isConfirmed}} {{confirmations}} confirmations {{else}}Unconfirmed{{/if}}</div>
            <div class="item"><strong>Block</strong> <a href="{{nodeExplorerUrl}}/block/{{tx.header.block_number}}">{{tx.header.block_number}}</a></div>
            <div class="item"><strong>Nonce</strong> {{tx.tx.nonce}}</div>
            <div class="item"><strong>OTS key</strong> {{tx.tx.ots_key}}</div>
            <div class="item"><strong>Fee</strong> {{tx.tx.fee}} Quanta</div>
            <!-- <div class="item"><strong>Size</strong> {{txSize}}</div>             -->
            <div class="item"><strong>Status</strong> {{#if isConfirmed}} OK <i class="ui green circle icon"></i> {{ts}} {{else}} Unconfirmed <i class="ui yellow circle icon"></i>{{/if}}</div>
          </div>
          <div class="ui hidden divider"></div>
        </div>

        <div class="ui bottom attached tab segment active">
          <div class="ui stackable grid">
            <div class="sixteen wide column">
              <div class="ui basic center aligned segment">
                <div class="ui statistic">

                  <div class="label">
                    <div class="ui {{color}} label">{{explorer.type}}{{#if isTokenTransfer}}: {{explorer.symbol}} {{/if}}</div>
                  </div>
                  
                  {{#if isNotMessage}}
                    {{#if isToken}}
                      <strong>{{explorer.name}} ({{explorer.symbol}})</strong><br />
                      owned by:<br />
                      <a href="{{nodeExplorerUrl}}/a/{{# if bech32}}{{explorer.owner_b32}}{{else}}{{explorer.owner_hex}}{{/if}}">{{# if bech32}}{{explorer.owner_b32}}{{else}}{{explorer.owner_hex}}{{/if}}</a>
                    {{else}}
                      {{#if isTokenTransfer}}
                        <div class="value">{{explorer.totalTransferred}}</div>
                        {{explorer.symbol}} ({{explorer.name}})<br />
                        tokens transferred
                        <div class="label">Token creation transaction: </div>
                        <a href="{{nodeExplorerUrl}}/tx/{{explorer.token_txhash}}" class="unbreakable">{{explorer.token_txhash}}</a>
                      {{else}}
                      {{#if isMultiSigCreateTxn}}
                      {{else}}
                        <div class="value" data-html="<div class='content'>USD ${{qrl}}</div>">
                          {{tx.tx.amount}}
                        </div>
                        <div class="label">
                          Quanta<br><small>USD ${{qrl}}</small>
                        </div>
                        {{/if}}
                      {{/if}}
                    {{/if}}
                  {{/if}}
                </div>
              </div>
            </div>
          </div>

          {{#if isToken}}
            <h4>Initial balances</h4>
            <table class="ui stackable table">
              <thead>
                <th>Address</th>
                <th>Balance</th>
              </thead>
              <tbody>
                {{#each explorer.initialBalances}}
                  <tr>
                    <td><a href="{{nodeExplorerUrl}}/a/{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}">{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}</a></td>
                    <td>{{this.amount}}</td>
                  </tr>
                {{/each}}
              </tbody>
            </table>
          {{else}}
            {{#if isNotCoinbase}}
              <table class="ui stackable table">
                <tbody>
                  <tr>
                    <td class="single line">
                      <div class="ui red label"><i class="sign out icon"></i>from</div>
                    </td>
                    <td><a href="{{nodeExplorerUrl}}/a/{{# if bech32}}{{explorer.from_b32}}{{else}}{{explorer.from_hex}}{{/if}}">{{# if bech32}}{{explorer.from_b32}}{{else}}{{explorer.from_hex}}{{/if}}</a></td>
                  </tr>
                </tbody>
              </table>
            {{/if}}

            {{#if isMessage}}
              <h3>Message</h3>
              <p><pre>{{explorer.message}}</pre></p>
            {{else}}
              {{#if isDocumentNotarisation}}
                <h3>Document Notarisaion</h3>
                <span>Notary <a class="ui">{{# if bech32}}{{explorer.from_b32}}{{else}}{{explorer.from_hex}}{{/if}}</a></span>
                <br />
                <span>Hash Function <a class="ui">{{explorer.hash_function}}</a></span>
                <br />
                <span>File Hash <a class="ui">{{explorer.hash}}</a></span>
                <br />
                <span>Additional Text <a class="ui">{{explorer.text}}</a></span>
                <br />
              {{else}}
              {{#if isMultiSigCreateTxn}}
                  <h4>Signatories</h4>
                  <table class="ui table">
                    <thead><th>Address</th><th>Weight</th></thead>
                    <tbody>
                      {{#each multiSigSignatories this.tx.multi_sig_create}}
                      <tr>
                      <td>
                        <!-- {{# if bech32}}{{ this.address_b32 }}{{else}} -->
                        {{ this.address_hex}}
                        <!-- {{/if}} -->
                      </td>
                      <td>{{ this.weight }}</td>
                      </tr>
                      {{/each}}
                    </tbody>
                    <tfoot>
                      <th>Threshold for spend</th>
                      <th>{{ this.tx.multi_sig_create.threshold }}</th>
                    </tfoot>
                  </table>
                {{else}}
                {{#if isMultiSigVoteTxn}}
                <table class="ui table">
                  <tr>
                    <td><strong>Spend transaction</strong></td>
                    <td style="font-family: Hack;"><a href="/tx/{{ this.tx.multi_sig_vote.shared_key }}">{{ this.tx.multi_sig_vote.shared_key }}</a></td>
                  </tr>
                  <tr>
                      <td><strong>Vote status</strong></td>
                      <td>{{ #if this.tx.multi_sig_vote.unvote }}Approval revoked{{else}}Transaction approved{{/if}}</td>
                  </tr>
                </table>
                {{else}}
                <h3>To</h3>
                <table class="ui stackable table">
                  <thead>
                    <th>Address</th>
                    <th>Amount</th>
                  </thead>
                  <tbody>
                    {{#if isTransfer}}
                      {{#each explorer.outputs}}
                        <tr>
                          <td><a href="{{nodeExplorerUrl}}/a/{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}">{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}</a></td>
                          <td>{{this.amount}}</td>
                        </tr>
                      {{/each}}
                    {{else if isTokenTransfer}}
                      {{#each explorer.outputs}}
                        <tr>
                          <td><a href="{{nodeExplorerUrl}}/a/{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}">{{#if bech32}}{{this.address_b32}}{{else}}{{this.address_hex}}{{/if}}</a></td>
                          <td>{{this.amount}}</td>
                        </tr>
                      {{/each}}
                    {{else}}
                      <tr>
                        <td><a href="{{nodeExplorerUrl}}/a/{{# if bech32}}{{explorer.to_b32}}{{else}}{{explorer.to_hex}}{{/if}}">{{# if bech32}}{{explorer.to_b32}}{{else}}{{explorer.to_hex}}{{/if}}</a></td>
                        <td>{{tx.tx.amount}}</td>
                      </tr>
                    {{/if}}
                  </tbody>
                </table>
                {{/if}}
              {{/if}}
              {{/if}}
            {{/if}}
          {{/if}}
          <button class="ui mini button jsonclick">Meta <i class="down angle icon"></i></button>
          <div class="ui raised segment jsonbox json" style="display: none">{{json}}</div>
        </div>
      </div>

    {{/if}}
  {{/if}}
{{/with}}

</template>